//保存路由信息
export default [
    {
        path:'/',
        redirect:'/home'
    },{
        path:'/Center',
        name:'Center',
        //重定向到个人订单页面
        redirect:'/Center/myOrder',
        component:()=>
            import(/* webpackChunkName: "Center" */'@/pages/Center/index.vue'),
            meta:{show:true},
            children:[
                {
                    path:'myOrder',
                    name:'myOrder',
                    component:()=>
                        import(/* webpackChunkName: "myOrder" */'@/pages/Center/myOrder/index.vue'),
                        meta:{show:true}
                }
            ]
    },{
        path:'/ShopCart',
        name:'ShopCart',
        component:()=>
            import(/* webpackChunkName: "ShopCart" */'@/pages/ShopCart/index.vue'),
            meta:{show:true}
    },{
        path:'/AddCartSuccess',
        name:'AddCartSuccess',
        component:()=>
         import(/* webpackChunkName: "AddCartSuccess" */'@/pages/AddCartSuccess/index.vue'),
         meta:{show:true}
    },{
        path:'/detail/:skuid',
        // name:'detail',
        component:()=>
            import(/* webpackChunkName: "Detail" */'@/pages/Detail/index.vue'),
            meta:{show:true}
    },{
        path: '/home',
        component: () =>
            import (/* webpackChunkName: "Home" */'@/pages/Home/index.vue'),
            meta:{show:true} // 添加元信息根据这边来决定是否显示底部模块
    },{
        path: '/search/:keyword?',//加一个问号代表着可传可不传
        name:'search', //动态路由必须要要加上这个
        component: () =>
            import (/* webpackChunkName: "Search" */'@/pages/Search/index.vue'),
            meta:{show:true},
            //布尔写法 让路由接受props,需要与动态路由配合使用
            // props:true,
            //对象写法 或者可以用对象的方式额外传入参数
            //props:{a:1,b:2},
            //函数写法,常用并且灵活
            props:(route)=>{
                return {keyword:route.query.categoryName}
            }
    },{
        path: '/login',
        component: () =>
            import (/* webpackChunkName: "Login" */'@/pages/Login/index.vue'),
            meta:{show:true}
    },{
        path: '/register',
        component: () =>
            import (/* webpackChunkName: "Register" */'@/pages/Register/index.vue') ,
            meta:{show:true}
    },{
        path:'/Trade',
        name:'Trade',
        component: () =>
            import (/* webpackChunkName: "Trade" */'@/pages/Trade/index.vue'),
            meta:{show:true},
            beforeEnter: (to, from, next) => {
                if (from.path === "/ShopCart") {
                    next();
                  } else {
                    next("/home");
                  }
            }
    },{
        path:'/Pay',
        name:'Pay',
        component:()=>
            import(/* webpackChunkName: "Pay" */'@/pages/Pay/index.vue'),
            meta:{show:true},
            //只有从购物车页面才能进入
            beforeEnter: (to, from, next) => {
                if (from.path === "/Trade") {
                    next();
                  } else {
                    next("/home");
                  }
            }
    },{
        path:'/PaySuccess',
        name:'PaySuccess',
        component:()=>
            import(/* webpackChunkName: "PaySuccess" */'@/pages/PaySuccess/index.vue'),
            meta:{show:true}
    }
]
